
package com.dave.gd.common.util.xml.type;

import org.apache.commons.lang.math.NumberUtils;

/**
 * Short类型转换
 * 
 * 
 * 
 */
public class TypeShort implements ITypeConverter {
	private static Short ZERO = Integer.valueOf(0).shortValue();

	/**
	 * string转为short
	 * 
	 */
	@Override
	public Object getValue(String text) {
		if (text == null) {
			return ZERO;
		}
		return NumberUtils.toShort(text);
	}

	/**
	 * short转为string
	 * 
	 */
	@Override
	public String getText(Object value) {
		if (value == null) {
			return null;
		}
		return value.toString();
	}

}
